using System.Linq; public class Program { public static int DuplicateCount(string str) { return str.ToCharArray() .GroupBy(x => x) .Where(x => x.Count() > 1) .Count(); } }